package base.spring.event;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.context.ApplicationContext;
import org.springframework.context.event.ApplicationContextEvent;
import org.springframework.stereotype.Component;

/**
 * @author : GuoFei
 * @since : 2019/7/12 13:50
 */
@Component
public class MyOneEvent extends ApplicationContextEvent {

    private JSONObject jo;

    /**
     * Create a new ContextStartedEvent.
     *
     * @param source the {@code ApplicationContext} that the event is raised for
     *               (must not be {@code null})
     */
    public MyOneEvent(ApplicationContext source,JSONObject newJo) {
        super(source);
        jo = newJo;
        System.out.println("MyOneEvent.MyOneEvent 执行了");
    }

    public void run(){
        System.out.println("我的事件"+ JSON.toJSONString(jo.values()));
    }

}
